package com.loongnoy.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.loongnoy.model.Customer;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CustomerMapper extends BaseMapper<Customer> {

    /**
     * 插入客户信息
     *
     * @param customer 客户对象，包含客户信息
     * @return 插入成功的记录数
     */
    @Insert("INSERT INTO t_customer (username, job, phone, sex) VALUES (#{username}, #{job}, #{phone}, #{sex})")
    int insert(Customer customer);

    /**
     * 查询姓“张”的所有男性客户信息
     *
     * @return 客户列表
     */
    @Select("SELECT * FROM t_customer WHERE username LIKE '张%' AND sex = 1")
    List<Customer> selectZhangMen();

    /**
     * 将“王五”的工作职位修改为“总经理”
     *
     * @return 更新成功的记录数
     */
    @Update("UPDATE t_customer SET job = '总经理' WHERE username = '王五'")
    int updateWangWuJob();

    /**
     * 删除所有职位为“程序员”的客户信息
     *
     * @return 删除成功的记录数
     */
    @Delete("DELETE FROM t_customer WHERE job = '程序员'")
    int deleteProgrammers();
}
